//
//  CCLoginViewController.m
//  BuDeJie
//
//  Created by demoncraz on 2017/2/12.
//  Copyright © 2017年 demoncraz. All rights reserved.
//

#import "CCLoginViewController.h"
#import "CCLoginView.h"
#import "CCQuickLoginView.h"
#import "UIView+Frame.h"

@interface CCLoginViewController ()
@property (weak, nonatomic) IBOutlet UIView *middleView;
@property (weak, nonatomic) IBOutlet UIView *bottomView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *middleLeading;

@end

@implementation CCLoginViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    //初始化中间视图
    CCLoginView *loginView = [CCLoginView loginView];
    CCLoginView *registerView = [CCLoginView registerView];
    registerView.CC_x = self.middleView.CC_width * 0.5;
    [self.middleView addSubview:loginView];
    
    [self.middleView addSubview:registerView];
    
    //初始化底部视图
    CCQuickLoginView *quickLoginView = [CCQuickLoginView quickLoginView];
    [self.bottomView addSubview:quickLoginView];
    
    
    
    
}

- (void)viewDidLayoutSubviews {
    [super viewDidLayoutSubviews];
    
    //调整子控件布局
    CCLoginView *loginView = self.middleView.subviews[0];
    loginView.frame = CGRectMake(0, 0, self.middleView.CC_width * 0.5, self.middleView.CC_height);
    
    CCLoginView *registerView = self.middleView.subviews[1];
    registerView.frame = CGRectMake(self.middleView.CC_width * 0.5, 0, self.middleView.CC_width * 0.5, self.middleView.CC_height);
    
}



- (IBAction)closeBtnClick:(id)sender {
    
    [self dismissViewControllerAnimated:YES completion:nil];
    
}
- (IBAction)loginRegsiterBtnClick:(UIButton *)button {
    button.selected = !button.selected;
    self.middleLeading.constant = self.middleLeading.constant == 0 ? -self.middleView.CC_width * 0.5 : 0;
    
    [UIView animateWithDuration:0.3 animations:^{
        [self.view layoutIfNeeded];
    }];
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
